package com.cduestc.mylogin;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;

public class Evaluation extends AppCompatActivity {

    RatingBar ratingBar;
    Button commitBtn;
    TextView evaluation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_evaluation);

        ratingBar = this.findViewById(R.id.ratingBar);
        commitBtn = this.findViewById(R.id.commitBtn);
        evaluation = this.findViewById(R.id.evaluation);

        commitBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(Evaluation.this, "感谢您的评价", Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(Evaluation.this,HomePage.class);
                startActivity(intent);
            }
        });

        ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float v, boolean b) {
                if(v == 1.0){
                    evaluation.setText("非常不满意");
                }else if(v == 2.0){
                    evaluation.setText("不满意");
                }else if(v == 3.0){
                    evaluation.setText("一般");
                }else if(v == 4.0){
                    evaluation.setText("满意");
                }else if(v == 5.0){
                    evaluation.setText("非常满意");
                }
            }
        });
    }
}